#ifndef VARIABLE_H
#define VARIABLE_H

#include <map>
#include <set>
#include <string>

namespace fcsp {
class Variable {
 public:
  // constructors
  Variable();
  Variable(std::map<int, double> preferences);

  // destructors
  virtual ~Variable() { }
    
  // accessors
  const int id() const { return id_; }
  const std::string name() const { return name_; }
  const std::map<int, double> &preferences() const { return preferences_; }
  const std::set<Variable*> &adjacents() const { return adjacents_; }

  // mutators
  void set_name(std::string name) { name_ = name; }
  
  // operators
  // unique identifiers are compared
  inline bool operator<(const Variable &v) const { return id() < v.id(); }
  inline bool operator>(const Variable &v) const { return id() > v.id(); }
  inline bool operator<=(const Variable &v) const { return id() <= v.id(); }
  inline bool operator>=(const Variable &v) const { return id() >= v.id(); }
  inline bool operator==(const Variable &v) const { return id() == v.id(); }
  inline bool operator!=(const Variable &v) const { return id() != v.id(); }
  
  // methods
  void AddAdjacent(Variable &adjacent); // add an adjacent node
  void RemoveAdjacent(Variable &adjacent); // remove an adjacent node
  void RemoveValue(int value); // remove a value
  bool IsValue(int value); // check if value is valid
  double GetPreference(int value); // get a preference of value
  void SetPreference(int value, double preference); // set a preference of value

 private:
  static int seed_;
  int id_; // unique id
  std::string name_; // name of the node
  std::map<int, double> preferences_; // list of preferences
  std::set<Variable*> adjacents_; // list of adjacents nodes
}; // class Variable
} // namespace fcsp
#endif	// VARIABLE_H

